package xyz.xtt.schedule.constants;

import xyz.xtt.common.starter.cache.CacheConfig;
import xyz.xtt.schedule.entity.TblRegion;

import java.util.concurrent.TimeUnit;

/**
 * Schedule项目缓存配置枚举
 *
 * @author dale
 * @since 2025/1/2
 **/
public enum ScheduleCacheConfig implements CacheConfig {
    /**
     * 行政区划数据缓存
     */
    REGION_CACHE("luck_phone_region", 20, TimeUnit.MINUTES, TblRegion.class);
    /**
     * 缓存key前缀
     */
    private String prefix;
    /**
     * 缓存时长
     */
    private long ttl;
    /**
     * 缓存时长单位
     */
    private TimeUnit timeUnit;
    /**
     * 缓存序列化对象类型
     */
    private Class<?> clazz;

    ScheduleCacheConfig(String prefix, long ttl, TimeUnit timeUnit, Class<?> clazz) {
        this.prefix = prefix;
        this.ttl = ttl;
        this.timeUnit = timeUnit;
        this.clazz = clazz;
    }

    @Override
    public String prefix() {
        return prefix;
    }

    @Override
    public long ttl() {
        return ttl;
    }

    @Override
    public TimeUnit timeUnit() {
        return timeUnit;
    }

    @Override
    public Class<?> clazz() {
        return clazz;
    }
}
